//
//  NYTabBarViewController.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2017/10/26.
//  Copyright © 2017年 niuwaketang. All rights reserved.
//

#import "NYTabBarViewController.h"
#import "NYTabBarViewController.h"

@interface NYTabBarViewController () <UITabBarControllerDelegate>
@property (strong, nonatomic) NSMutableDictionary <NSString *,__kindof UIViewController *>*vcStoreDict;
@end

@implementation NYTabBarViewController
- (instancetype)init
{
        self = [super init];
        if (self) {
                self.delegate = self;
        }
        return self;
}
- (void)addTabBarController:(__kindof UIViewController *)vc atIndex:(NSInteger)index
{
        if (vc == nil)
        {
                return;
        }
        [self.vcStoreDict setObject:vc forKey:[NSString stringWithFormat:@"%d",(int)index]];
        [self setViewControllers:[self.vcStoreDict allValuesSortedByKeys] animated:NO];
        [self setSelectedIndex:0];
}
- (NSMutableDictionary<NSString *,UIViewController *> *)vcStoreDict
{
        if (_vcStoreDict == nil) {
                _vcStoreDict = [[NSMutableDictionary alloc] init];
        }
        return _vcStoreDict;
}
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
        return YES;
}
@end
